package com.xs.bookspoststation.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.xs.bookspoststation.R;
import com.xs.bookspoststation.bean.User;

import java.util.List;

public class UserAdapter extends ArrayAdapter {
    //实体类
    User user;

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public long getItemId(int position){
        return position;

    }

    public UserAdapter(Context context, int resource, List<User> userlist) {
        super(context, resource, userlist);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        user = (User)getItem(position);
        View view= LayoutInflater.from(getContext()).inflate(R.layout.userlist, null);

        TextView user_sel_username2 =(TextView)view.findViewById(R.id.user_sel_username2);
        TextView user_sel_password2 =(TextView)view.findViewById(R.id.user_sel_password2);
        TextView user_sel_phone2 =(TextView)view.findViewById(R.id.user_sel_phone2);
        TextView user_sel_sex3 =(TextView)view.findViewById(R.id.user_sel_sex3);
        TextView user_sel_hobby2 =(TextView)view.findViewById(R.id.user_sel_hobby2);
        TextView user_sel_education2 =(TextView)view.findViewById(R.id.user_sel_education2);
        TextView user_sel_fullname2 =(TextView)view.findViewById(R.id.user_sel_fullname2);
        TextView user_sel_email2 =(TextView)view.findViewById(R.id.user_sel_email2);
        TextView user_sel_province2 =(TextView)view.findViewById(R.id.user_sel_province2);
        TextView user_sel_school2 =(TextView)view.findViewById(R.id.user_sel_school2);
        user_sel_username2.setText(user.getUsername());
        user_sel_password2.setText(user.getUserpwd());
        user_sel_phone2.setText(user.getUserphone());
        user_sel_sex3.setText(user.getUsersex());
        user_sel_hobby2.setText(user.getUserhobby());
        user_sel_education2.setText(user.getUsereducation());
        user_sel_fullname2.setText(user.getUserfullname());
        user_sel_email2.setText(user.getUseremail());
        user_sel_province2.setText(user.getUserprovince());
        user_sel_school2.setText(user.getUserschool());
        return view;

    }
}
